/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cadastros;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import utilitarios.conexao;
import javax.swing.text.MaskFormatter;
import java.util.Date;
import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Eli
 */
public class funcionario extends javax.swing.JFrame {

    conexao con_funcionario, con_cidade, con_bairro, con_logradouro, con_cargo;
    int navega = 0; // variavel para sabermos qual botao foi clicado
    int inicia_combo = 0;
    String ordenacao = "nome", sexo="M";
    MaskFormatter formatoCpf, formatoCep, formatoFoneRes, formatoFoneCom, formatoFoneCel, formatoDataNasc, formatoDataCad;
    boolean primeiraVezCidade=true, primeiraVezBairro=true, primeiraVezLog=true, primeiraVezCargo=true;    
    
    /**
     * Creates new form cad_funcionario
     */
    public funcionario() {
        initComponents();
        
        con_funcionario = new conexao();
        con_funcionario.conecta();
        con_funcionario.executeSQL("select * from funcionario order by "+ ordenacao);
        
        con_cidade = new conexao();
        con_cidade.conecta();
        con_cidade.executeSQL("select * from cidade order by nome");
        
        con_bairro = new conexao();
        con_bairro.conecta();
        con_bairro.executeSQL("select * from bairro order by nome");
        
        con_logradouro = new conexao();
        con_logradouro.conecta();
        con_logradouro.executeSQL("select * from logradouro order by nome");
        
        con_cargo = new conexao();
        con_cargo.conecta();
        con_cargo.executeSQL("select * from cargo order by nome");
        
        try
        {
            while( con_funcionario.resultset.next() )
            {
                jcb_pesquisa.addItem(con_funcionario.resultset.getString("nome"));
            }
            
            while( con_cidade.resultset.next() )
            {
                cb_cidade.addItem(con_cidade.resultset.getString("nome"));
            }
            
            while( con_bairro.resultset.next() )
            {
                cb_bairro.addItem(con_bairro.resultset.getString("nome"));
            }
            
            while( con_logradouro.resultset.next() )
            {
                cb_logradouro.addItem(con_logradouro.resultset.getString("nome"));
            }
            
            while( con_cargo.resultset.next() )
            {
                cb_cargo.addItem(con_cargo.resultset.getString("nome"));
            }
            
            con_funcionario.resultset.first();
            mostrar_dados();
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não localizou dados"+erro);
        }
        
        preencher_jtable(); // chama metodo para preenchee jtable
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupo_ordenacao = new javax.swing.ButtonGroup();
        grupo_sexo = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        tf_codigo = new javax.swing.JTextField();
        tf_nome = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cb_logradouro = new javax.swing.JComboBox();
        botao_primeiro = new javax.swing.JButton();
        botao_anterior = new javax.swing.JButton();
        botao_proximo = new javax.swing.JButton();
        botao_ultimo = new javax.swing.JButton();
        botao_gravar = new javax.swing.JButton();
        botao_inserir = new javax.swing.JButton();
        botao_excluir = new javax.swing.JButton();
        botao_alterar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        tf_pesquisa = new javax.swing.JTextField();
        jcb_pesquisa = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        rb_codigo = new javax.swing.JRadioButton();
        rb_nome = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();
        tf_codLog = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tf_numero = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tf_complemento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tf_codBairro = new javax.swing.JTextField();
        cb_bairro = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        tf_codCidade = new javax.swing.JTextField();
        cb_cidade = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        try
        {
            formatoCep = new MaskFormatter("#####-###");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_cep = new JFormattedTextField(formatoCep);
        jLabel12 = new javax.swing.JLabel();
        tf_rg = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        try
        {
            formatoDataNasc = new MaskFormatter("##/##/####");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_datanasc = new JFormattedTextField(formatoDataNasc);
        try
        {
            formatoFoneCom = new MaskFormatter("(##) ####-####");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_fonecom = new JFormattedTextField(formatoFoneCom);
        try
        {
            formatoFoneRes = new MaskFormatter("(##) ####-####");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_foneres = new JFormattedTextField(formatoFoneRes);
        jLabel17 = new javax.swing.JLabel();
        try
        {
            formatoFoneCel = new MaskFormatter("(##) ####-####");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_fonecel = new JFormattedTextField(formatoFoneCel);
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        tf_email = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        tf_dataadmin = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        tf_obs = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        tf_foto = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        lbFoto = new javax.swing.JLabel();
        try
        {
            formatoCpf = new MaskFormatter("###.###.###-##");
        }
        catch( Exception erro )
        {
            JOptionPane.showMessageDialog(null,"Não foi possivel setar a mascara, erro = "+erro);
        }
        tf_cpf = new JFormattedTextField(formatoCpf);
        jPanel4 = new javax.swing.JPanel();
        sexo_masc = new javax.swing.JRadioButton();
        sexo_fem = new javax.swing.JRadioButton();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        tf_cargo = new javax.swing.JTextField();
        cb_cargo = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Manutenção do Cadastro de Funcionários");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(204, 0, 0));
        jLabel1.setText("Manutenção do Cadastro de Funcionários");

        jLabel2.setText("Código:");

        jLabel3.setText("Nome:");

        cb_logradouro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_logradouroActionPerformed(evt);
            }
        });
        cb_logradouro.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_logradouroFocusLost(evt);
            }
        });

        botao_primeiro.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\primeiro_registro.gif")); // NOI18N
        botao_primeiro.setToolTipText("Primeiro registro");
        botao_primeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_primeiroActionPerformed(evt);
            }
        });

        botao_anterior.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\registro_anterior.gif")); // NOI18N
        botao_anterior.setToolTipText("Anterior");
        botao_anterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_anteriorActionPerformed(evt);
            }
        });

        botao_proximo.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\proximo_registro.gif")); // NOI18N
        botao_proximo.setToolTipText("Próximo");
        botao_proximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_proximoActionPerformed(evt);
            }
        });

        botao_ultimo.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\ultimo_registro.gif")); // NOI18N
        botao_ultimo.setToolTipText("Último registro");
        botao_ultimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_ultimoActionPerformed(evt);
            }
        });

        botao_gravar.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\gravar_registro.gif")); // NOI18N
        botao_gravar.setText("Gravar");
        botao_gravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_gravarActionPerformed(evt);
            }
        });

        botao_inserir.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\novo_registro.gif")); // NOI18N
        botao_inserir.setText("Inserir");
        botao_inserir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_inserirActionPerformed(evt);
            }
        });

        botao_excluir.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\delete.gif")); // NOI18N
        botao_excluir.setText("Excluir");
        botao_excluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_excluirActionPerformed(evt);
            }
        });

        botao_alterar.setIcon(new javax.swing.ImageIcon("C:\\Java\\NetBeansProjects\\Estoque\\imagens\\alterar_registro.gif")); // NOI18N
        botao_alterar.setText("Alterar");
        botao_alterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_alterarActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 51, 51));

        jLabel5.setText("Pesquisar:");

        tf_pesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_pesquisaActionPerformed(evt);
            }
        });

        jcb_pesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcb_pesquisaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(tf_pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcb_pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(tf_pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcb_pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21))
        );

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Código", "Nome", "Fone res.", "Fone com.", "Fone Cel.", "E-mail"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jPanel2.setBackground(new java.awt.Color(204, 255, 204));

        jLabel6.setText("Ordenação");

        grupo_ordenacao.add(rb_codigo);
        rb_codigo.setText("Código");
        rb_codigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_codigoActionPerformed(evt);
            }
        });

        grupo_ordenacao.add(rb_nome);
        rb_nome.setText("Nome");
        rb_nome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_nomeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rb_nome)
                    .addComponent(jLabel6)
                    .addComponent(rb_codigo))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rb_codigo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rb_nome)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setText("Filtrar na grade");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        tf_codLog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_codLogActionPerformed(evt);
            }
        });

        jLabel7.setText("Endereço:");

        jLabel4.setText("Nº:");

        jLabel8.setText("Complemento:");

        jLabel9.setText("Bairro:");

        tf_codBairro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_codBairroActionPerformed(evt);
            }
        });

        cb_bairro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_bairroActionPerformed(evt);
            }
        });
        cb_bairro.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_bairroFocusLost(evt);
            }
        });

        jLabel10.setText("Cidade:");

        tf_codCidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_codCidadeActionPerformed(evt);
            }
        });

        cb_cidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_cidadeActionPerformed(evt);
            }
        });
        cb_cidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_cidadeFocusLost(evt);
            }
        });

        jLabel11.setText("CEP:");

        jLabel12.setText("RG:");

        jLabel13.setText("CPF:");

        jLabel14.setText("Data de nascimento:");

        jLabel17.setText("Fone Cel:");

        tf_fonecel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_fonecelActionPerformed(evt);
            }
        });

        jLabel15.setText("Fone Res:");

        jLabel16.setText("Fone Com:");

        jLabel18.setText("E-mail:");

        jLabel19.setText("Data admissão:");

        jLabel20.setText("Observação:");

        jLabel21.setText("Foto:");

        jButton2.setText("...");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Impressão");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Consultas");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(204, 255, 204));

        jLabel22.setText("Foto");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addComponent(jLabel22)
                .addContainerGap(18, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbFoto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbFoto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel4.setBackground(new java.awt.Color(204, 255, 204));

        grupo_sexo.add(sexo_masc);
        sexo_masc.setSelected(true);
        sexo_masc.setText("Masculino");
        sexo_masc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sexo_mascActionPerformed(evt);
            }
        });

        grupo_sexo.add(sexo_fem);
        sexo_fem.setText("Feminino");
        sexo_fem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sexo_femActionPerformed(evt);
            }
        });

        jLabel23.setText("Sexo");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel23)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(10, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sexo_masc)
                    .addComponent(sexo_fem))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jLabel23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(sexo_masc)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(sexo_fem)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jLabel24.setText("Cargo:");

        tf_cargo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_cargoActionPerformed(evt);
            }
        });
        tf_cargo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tf_cargoFocusLost(evt);
            }
        });

        cb_cargo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_cargoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel20)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel7)
                                        .addGap(18, 18, 18)
                                        .addComponent(tf_codLog, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cb_logradouro, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tf_codBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(cb_bairro, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tf_complemento))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tf_codCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cb_cidade, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tf_cep, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(botao_primeiro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_anterior)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_proximo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_ultimo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_inserir)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_gravar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_excluir)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botao_alterar))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tf_foneres, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tf_rg, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tf_cpf, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel14))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(tf_obs, javax.swing.GroupLayout.PREFERRED_SIZE, 479, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel18)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tf_email, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel19)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tf_dataadmin, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addGap(185, 185, 185)
                                        .addComponent(jLabel16)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tf_fonecom, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel17)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tf_fonecel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(tf_datanasc, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(79, 79, 79)
                                                .addComponent(jLabel1))
                                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jLabel2)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(tf_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(jLabel3)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(tf_nome, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGap(18, 18, 18)
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tf_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cb_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(34, 34, 34))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 714, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(376, 376, 376)))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel2)
                                    .addComponent(tf_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tf_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)))
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tf_codLog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(cb_logradouro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)
                            .addComponent(tf_complemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cb_bairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10)
                                .addComponent(tf_codCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(cb_cidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel11)
                                .addComponent(tf_cep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(tf_codBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(tf_rg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(tf_datanasc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tf_cpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tf_fonecom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17)
                            .addComponent(tf_fonecel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tf_foneres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)
                            .addComponent(jLabel16))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tf_email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel18)
                            .addComponent(jLabel19)
                            .addComponent(tf_dataadmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tf_obs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel20)))
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(jButton2)
                    .addComponent(jLabel24)
                    .addComponent(tf_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(botao_gravar)
                        .addComponent(botao_excluir)
                        .addComponent(botao_alterar)
                        .addComponent(botao_inserir))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(botao_anterior, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(botao_proximo, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(botao_ultimo, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(botao_primeiro)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                .addContainerGap())
        );

        setSize(new java.awt.Dimension(776, 638));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void botao_primeiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_primeiroActionPerformed
        // TODO add your handling code here:
        
        try
        {
            con_funcionario.resultset.first();
            mostrar_dados();
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não foi possivel ir para o primeiro registro: "+erro);
        }
        
    }//GEN-LAST:event_botao_primeiroActionPerformed

    private void botao_gravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_gravarActionPerformed
        // TODO add your handling code here:
      
        try
        {
            String sqlinsert ="insert into funcionario " +
                    "(nome,logradouro,numero,complemento,bairro,cidade," +
                    "cep,RG,CPF,foneres,fonecom,fonecel,email,datanascimento," +
                    "sexo,dataadmissao,foto,observacao) values ('"+
                    tf_nome.getText()+"','"+                    
                    tf_codLog.getText()+"','"+
                    tf_numero.getText()+"','"+
                    tf_complemento.getText()+"','"+
                    tf_codBairro.getText()+"','"+
                    tf_codCidade.getText()+"','"+
                    tf_cep.getText()+"','"+
                    tf_rg.getText()+"','"+
                    tf_cpf.getText()+"','"+
                    tf_foneres.getText()+"','"+
                    tf_fonecom.getText()+"','"+
                    tf_fonecel.getText()+"','"+
                    tf_email.getText()+"','"+
                    tf_datanasc.getText()+"','"+
                    sexo+"','"+
                    tf_dataadmin.getText()+"','"+
                    tf_foto.getText()+"','"+
                    tf_obs.getText()+"')";
            
            con_funcionario.statement.executeUpdate(sqlinsert);
            JOptionPane.showMessageDialog(null, "gravação realizada com sucesso");
            
            // atualiza o resutset
            //con_funcionario.resultset = con_funcionario.statement.executeQuery("select * from funcionario");
            con_funcionario.executeSQL("select * from funcionario order by "+ ordenacao);
            atualiza_combo_box_funcionario();
            con_funcionario.resultset.first();    // posiciona no primeiro registro
            mostrar_dados();
        }
        catch( SQLException erro )
        {
            JOptionPane.showMessageDialog(null, "erro ao tentar gravar registro: "+erro);
        }
        
    }//GEN-LAST:event_botao_gravarActionPerformed

    private void botao_inserirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_inserirActionPerformed
        // TODO add your handling code here:
        
        // limpa os campos
        tf_codigo.setText("");
        tf_nome.setText("");     
        tf_codLog.setText("");
        tf_numero.setText("");
        tf_complemento.setText("");
        tf_codBairro.setText("");
        tf_codCidade.setText("");
        tf_cep.setText("");
        tf_rg.setText("");
        tf_cpf.setText("");
        tf_foneres.setText("");
        tf_fonecom.setText("");
        tf_fonecel.setText("");
        tf_email.setText("");
        tf_dataadmin.setText("");
        tf_cargo.setText("");
        
        //rorina par inserir data atual ao novo registro
        Date data = new Date();
        String dia    = ""+data.getDate(); 
        String mes   = ""+String.valueOf(data.getMonth()+1); 
        String ano    = ""+(1900 + data.getYear());
        if (Integer.parseInt(mes)<=9)
            mes="0"+mes;
        tf_dataadmin.setText(dia+mes+ano);
        
        tf_obs.setText("");
        tf_foto.setText("semfoto.jpg");
        lbFoto.setIcon(new ImageIcon("imagens/"+tf_foto.getText()));
        
        tf_nome.requestFocus(); // coloca em foco
        tf_codigo.setEditable(false);   // desabilita o campo
    }//GEN-LAST:event_botao_inserirActionPerformed

    private void botao_excluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_excluirActionPerformed
        // TODO add your handling code here:
        
        try
        {
            String sql = "select * from funcionario Where codigo = "+tf_codigo.getText();
            con_funcionario.executeSQL(sql); 
            con_funcionario.resultset.first();
            String nome = "Deletar a Cidade : "+con_funcionario.resultset.getString("nome")+" ?";
            int opcao_escolhida = JOptionPane.showConfirmDialog(null,nome,"Exclusão ",JOptionPane.YES_NO_OPTION);
            
            if (opcao_escolhida == JOptionPane.YES_OPTION)
            {
                sql = "DELETE FROM funcionario Where codigo ="+tf_codigo.getText();
                int conseguiu_excluir = con_funcionario.statement.executeUpdate(sql);
                if (conseguiu_excluir == 1)
                {
                    JOptionPane.showMessageDialog(null,"Exclusão realizada com sucesso");
                    
                    con_funcionario.executeSQL("select * from funcionario order by "+ ordenacao);
                    atualiza_combo_box_funcionario();
                    con_funcionario.resultset.first();   // posiciona no primeiro registro
                    mostrar_dados(); //irá chamar a função em que irá mstrar os dados no form
                    
                }
            } 	
            else
            {
                return;
            }
        }
        catch( SQLException erro )
        {
            JOptionPane.showMessageDialog(null, "erro ao tentar excluir o registro: "+erro);
        }
    }//GEN-LAST:event_botao_excluirActionPerformed

    private void botao_alterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_alterarActionPerformed
        // TODO add your handling code here:
        
        try
        {
            String sql ="UPDATE funcionario SET nome ='"+tf_nome.getText()+"',"+
                    "logradouro = '" +tf_codLog.getText()+"',"+
                    "numero = ' " +tf_numero.getText()+"',"+
                    "complemento = '" +tf_complemento.getText()+"',"+
                    "bairro = '" + tf_codBairro.getText()+"',"+
                    "cidade = '" + tf_codCidade.getText()+"',"+
                    "cep = '" + tf_cep.getText()+"',"+
                    "RG = '" + tf_rg.getText()+"',"+
                    "CPF = '" +tf_cpf.getText()+"',"+
                    "foneres = '" +tf_foneres.getText()+"',"+
                    "fonecom = '"  +tf_fonecom.getText()+"',"+
                    "fonecel = '"  +tf_fonecel.getText()+"',"+
                    "email = '"  +tf_email.getText()+"',"+
                    "datanascimento = '"  +tf_datanasc.getText()+"',"+
                    "dataadmissao = '"  +tf_dataadmin.getText()+"',"+
                    "foto = '"  +tf_foto.getText()+"',"+
                    "sexo = '" +sexo+"',"+
                    "observacao = '"  +tf_obs.getText()+
                    "' where codigo = "+tf_codigo.getText();
                
                    con_funcionario.statement.executeUpdate(sql);
                    JOptionPane.showMessageDialog(null,"Alteração realizado com sucesso!");
            
            //atualiza o ResultSet
            con_funcionario.executeSQL("Select * from funcionario  order by "+ordenacao);
            atualiza_combo_box_funcionario();
            con_funcionario.resultset.next(); //posiciona no primeiro registro
            mostrar_dados(); //irá chamar a função em que irá mstrar os dados no form
        }
        catch (SQLException erro)
        {
            JOptionPane.showMessageDialog(null,"Erro a tentar Alterar o registro..."+erro);
        }
        
    }//GEN-LAST:event_botao_alterarActionPerformed

    private void botao_proximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_proximoActionPerformed
        // TODO add your handling code here:
        
        try
        {
            con_funcionario.resultset.next();
            mostrar_dados();
            navega = 2;
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não foi possivel ir para o proximo registro"+erro);
        }
        
    }//GEN-LAST:event_botao_proximoActionPerformed

    private void botao_ultimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_ultimoActionPerformed
        // TODO add your handling code here:
        
        try
        {
            con_funcionario.resultset.last();
            mostrar_dados();
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não foi possivel ir para o ultimo registro"+erro);
        }
        
    }//GEN-LAST:event_botao_ultimoActionPerformed

    private void botao_anteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_anteriorActionPerformed
        // TODO add your handling code here:
        
        try
        {
           con_funcionario.resultset.previous();
           mostrar_dados();
           navega = 1;
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não foi possivel ir para o registro anterior: "+erro);
        }
        
    }//GEN-LAST:event_botao_anteriorActionPerformed

    private void jcb_pesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcb_pesquisaActionPerformed
        // TODO add your handling code here:
        
        if( inicia_combo == 1 )
        {
            try
            {
                con_funcionario.resultset.first();
                String igual = "n";

                while( igual == "n" )
                {
                   if( con_funcionario.resultset.getString("nome").equals(jcb_pesquisa.getSelectedItem()) )
                    {
                        igual = "s";
                    }
                    else
                    {
                        con_funcionario.resultset.next();
                    }
                }

                // mostra o conteudo da tabela
                tf_codigo.setText(con_funcionario.resultset.getString("codigo"));
                mostrar_dados();
            }
            catch( SQLException erro )
            { 
                //JOptionPane.showMessageDialog(null, "Não conseguiu localizar via digitação, erro = "+erro);
            }
        }
        
        inicia_combo = 1;
        
    }//GEN-LAST:event_jcb_pesquisaActionPerformed

    private void tf_pesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_pesquisaActionPerformed
        // TODO add your handling code here:
        
        try
        {
            con_funcionario.resultset.first();
            String igual = "n";
            int tamanho_pesquisa = tf_pesquisa.getText().length();
            
            while( igual == "n" )
            {
                String pesquisado = con_funcionario.resultset.getString("").substring(0, tamanho_pesquisa);
                
                if( pesquisado.equals(tf_pesquisa.getText()))
                {
                    igual = "s";
                }
                else
                {
                    con_funcionario.resultset.next();
                }
            }
            
            // mostra o conteudo da tabela
            tf_codigo.setText(con_funcionario.resultset.getString("codigo"));
            mostrar_dados();
            
            jcb_pesquisa.setSelectedItem(tf_nome.getText()); // atualiza combo
        }
        catch( SQLException erro )
        { 
            JOptionPane.showMessageDialog(null, "Não conseguiu localizar via digitação, erro = "+erro);
        }
        
    }//GEN-LAST:event_tf_pesquisaActionPerformed

    private void rb_codigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_codigoActionPerformed
        // TODO add your handling code here:
        
        ordem_visualizacao("codigo");
        
    }//GEN-LAST:event_rb_codigoActionPerformed

    private void rb_nomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_nomeActionPerformed
        // TODO add your handling code here:
        
        ordem_visualizacao("nome");
        
    }//GEN-LAST:event_rb_nomeActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        
        con_funcionario.executeSQL("select * from funcionario where nome like '"+tf_pesquisa.getText()+"%' order by "+ordenacao);          
        preencher_jtable();
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tf_fonecelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_fonecelActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_fonecelActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        
        try
        {
                JFileChooser busca_foto = new JFileChooser();
                busca_foto.setCurrentDirectory(new File("/estoque/imagens/"));        
                busca_foto.setDialogTitle("Carregar imagem do Cliente");         
                busca_foto.showOpenDialog(this);
                String foto = ""+busca_foto.getSelectedFile().getName();
                tf_foto.setText(foto);
                lbFoto.setIcon(new ImageIcon("imagens/"+tf_foto.getText()));
        }        
        catch(Exception erro)
        {
            JOptionPane.showMessageDialog(null,"Nao foi possível carregar a foto.");
        }
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton4ActionPerformed

    private void cb_cidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_cidadeActionPerformed
        // TODO add your handling code here:
        
        // procedimento para atualizar codigo da cidade
        if (primeiraVezCidade == false)
        {    
            try
            {
                String sql = "select * from cidade Where nome like '"+cb_cidade.getSelectedItem()+"'";
                con_cidade.executeSQL(sql);
                con_cidade.resultset.first();
                tf_codCidade.setText(con_cidade.resultset.getString("codigo"));
             }

            catch (SQLException erro)
            {
                JOptionPane.showMessageDialog(null,"Erro: "+erro);
            }
        }
        
        primeiraVezCidade=false;

    }//GEN-LAST:event_cb_cidadeActionPerformed

    private void cb_bairroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_bairroActionPerformed
        // TODO add your handling code here:
        
        // procedimento para atualizar codigo da cidade
        if (primeiraVezBairro == false)
        {    
            try
            {
                String sql = "select * from bairro Where nome like '"+cb_bairro.getSelectedItem()+"'";
                con_bairro.executeSQL(sql);
                con_bairro.resultset.first();
                tf_codBairro.setText(con_bairro.resultset.getString("codigo"));
             }

            catch (SQLException erro)
            {
                JOptionPane.showMessageDialog(null,"Erro: "+erro);
            }
        }
        primeiraVezBairro=false;
        
    }//GEN-LAST:event_cb_bairroActionPerformed

    private void cb_logradouroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_logradouroActionPerformed
        // TODO add your handling code here:
        
        // procedimento para atualizar codigo da cidade
        if (primeiraVezLog == false)
        {    
            try
            {
                String sql = "select * from logradouro Where nome like '"+cb_logradouro.getSelectedItem()+"'";
                con_logradouro.executeSQL(sql);
                con_logradouro.resultset.first();
                tf_codLog.setText(con_logradouro.resultset.getString("codigo"));
             }

            catch (SQLException erro)
            {
                JOptionPane.showMessageDialog(null,"Erro: "+erro);
            }
        }
        primeiraVezLog=false;
        
    }//GEN-LAST:event_cb_logradouroActionPerformed

    private void cb_logradouroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_logradouroFocusLost
        // TODO add your handling code here:
        
        atualizaComboBoxBairro();
        
    }//GEN-LAST:event_cb_logradouroFocusLost

    private void cb_cidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_cidadeFocusLost
        // TODO add your handling code here:
        
        atualizaComboBoxCid();
    }//GEN-LAST:event_cb_cidadeFocusLost

    private void cb_bairroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_bairroFocusLost
        // TODO add your handling code here:
        
        atualizaComboBoxBairro();
    }//GEN-LAST:event_cb_bairroFocusLost

    private void sexo_mascActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sexo_mascActionPerformed
        // TODO add your handling code here:
        
        sexo = "M";
    }//GEN-LAST:event_sexo_mascActionPerformed

    private void sexo_femActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sexo_femActionPerformed
        // TODO add your handling code here:
        
        sexo = "F";
    }//GEN-LAST:event_sexo_femActionPerformed

    private void tf_codLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_codLogActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_codLogActionPerformed

    private void tf_codCidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_codCidadeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_codCidadeActionPerformed

    private void tf_codBairroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_codBairroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_codBairroActionPerformed

    private void tf_cargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_cargoActionPerformed
        // TODO add your handling code here:
        
        
        
    }//GEN-LAST:event_tf_cargoActionPerformed

    private void cb_cargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_cargoActionPerformed
        // TODO add your handling code here:
        
        if (primeiraVezCargo == false)
        {
            try
        {
                String sql = "select * from cargo Where nome like '"+cb_cargo.getSelectedItem()+"'";
                con_cargo.executeSQL(sql);
                con_cargo.resultset.first();
                tf_cargo.setText(con_cargo.resultset.getString("codigo"));
            }
            
            catch (SQLException erro)
            {
                JOptionPane.showMessageDialog(null,"Erro a tentar excluir o registro..."+erro);
            }
        }
        primeiraVezCargo=false;
        
    }//GEN-LAST:event_cb_cargoActionPerformed

    private void tf_cargoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tf_cargoFocusLost
        // TODO add your handling code here:
        
        atualizaComboBoxCargo();
    }//GEN-LAST:event_tf_cargoFocusLost

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new funcionario().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botao_alterar;
    private javax.swing.JButton botao_anterior;
    private javax.swing.JButton botao_excluir;
    private javax.swing.JButton botao_gravar;
    private javax.swing.JButton botao_inserir;
    private javax.swing.JButton botao_primeiro;
    private javax.swing.JButton botao_proximo;
    private javax.swing.JButton botao_ultimo;
    private javax.swing.JComboBox cb_bairro;
    private javax.swing.JComboBox cb_cargo;
    private javax.swing.JComboBox cb_cidade;
    private javax.swing.JComboBox cb_logradouro;
    private javax.swing.ButtonGroup grupo_ordenacao;
    private javax.swing.ButtonGroup grupo_sexo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox jcb_pesquisa;
    private javax.swing.JLabel lbFoto;
    private javax.swing.JRadioButton rb_codigo;
    private javax.swing.JRadioButton rb_nome;
    private javax.swing.JRadioButton sexo_fem;
    private javax.swing.JRadioButton sexo_masc;
    private javax.swing.JTextField tf_cargo;
    private javax.swing.JTextField tf_cep;
    private javax.swing.JTextField tf_codBairro;
    private javax.swing.JTextField tf_codCidade;
    private javax.swing.JTextField tf_codLog;
    private javax.swing.JTextField tf_codigo;
    private javax.swing.JTextField tf_complemento;
    private javax.swing.JFormattedTextField tf_cpf;
    private javax.swing.JTextField tf_dataadmin;
    private javax.swing.JTextField tf_datanasc;
    private javax.swing.JTextField tf_email;
    private javax.swing.JTextField tf_fonecel;
    private javax.swing.JTextField tf_fonecom;
    private javax.swing.JTextField tf_foneres;
    private javax.swing.JTextField tf_foto;
    private javax.swing.JTextField tf_nome;
    private javax.swing.JTextField tf_numero;
    private javax.swing.JTextField tf_obs;
    private javax.swing.JTextField tf_pesquisa;
    private javax.swing.JTextField tf_rg;
    // End of variables declaration//GEN-END:variables

    public void mostrar_dados()
    {
        try
        {
            tf_codigo.setText(con_funcionario.resultset.getString("codigo"));
            tf_nome.setText(con_funcionario.resultset.getString("nome"));
            tf_codLog.setText(con_funcionario.resultset.getString("logradouro"));
            tf_numero.setText(con_funcionario.resultset.getString("numero"));
            tf_complemento.setText(con_funcionario.resultset.getString("complemento"));
            tf_codBairro.setText(con_funcionario.resultset.getString("bairro"));
            tf_codCidade.setText(con_funcionario.resultset.getString("cidade"));
            tf_cep.setText(con_funcionario.resultset.getString("cep"));
            tf_rg.setText(con_funcionario.resultset.getString("rg"));
            tf_cpf.setText(con_funcionario.resultset.getString("CPF"));
            tf_foneres.setText(con_funcionario.resultset.getString("FoneRes"));
            tf_fonecom.setText(con_funcionario.resultset.getString("FoneCom"));
            tf_fonecel.setText(con_funcionario.resultset.getString("FoneCel"));
            tf_email.setText(con_funcionario.resultset.getString("Email"));
            tf_datanasc.setText(con_funcionario.resultset.getString("DataNascimento"));
            tf_dataadmin.setText(con_funcionario.resultset.getString("dataadmissao"));
            tf_obs.setText(con_funcionario.resultset.getString("Observacao"));
            tf_foto.setText(con_funcionario.resultset.getString("foto"));
            lbFoto.setIcon(new ImageIcon("imagens/"+tf_foto.getText()));
            
            atualizaComboBoxLog();
            atualizaComboBoxCid();
            atualizaComboBoxBairro();
            
            // atualiza radio sexo
            if( con_funcionario.resultset.getString("sexo").equals("M") )
            {
                sexo_masc.setSelected(true);
            }
            else
            {
                sexo_fem.setSelected(true);
            }
        }
        catch( SQLException erro)
        {
            if( navega == 1 )
            {
                JOptionPane.showMessageDialog(null, "você já está no primeiro registro");
            }
            else if( navega == 2 )
            {
                JOptionPane.showMessageDialog(null, "você já está no último registro");
            }
            else
            {            
                JOptionPane.showMessageDialog(null, "não localizou dados"+erro);
                navega = 0;
            }
        }
    }
    
    public void atualiza_combo_box_funcionario()
    {
        try
        {
            jcb_pesquisa.removeAllItems();
            con_funcionario.executeSQL("select * from funcionario order by "+ ordenacao);
            
            while( con_funcionario.resultset.next() )
            {
                jcb_pesquisa.addItem(con_funcionario.resultset.getString("nome"));
            }
        }
        catch( SQLException erro)
        {
            JOptionPane.showMessageDialog(null, "não localizou dados"+erro);
        }
    }
    
    public void preencher_jtable()
    {
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(50);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(200);
        jTable1.getColumnModel().getColumn(2).setPreferredWidth(90);
        jTable1.getColumnModel().getColumn(3).setPreferredWidth(90);
        jTable1.getColumnModel().getColumn(4).setPreferredWidth(90);
        jTable1.getColumnModel().getColumn(5).setPreferredWidth(200);
        con_funcionario.executeSQL("select * from funcionario where nome like '"+tf_pesquisa.getText()+"%' order by "+ordenacao);
        
        DefaultTableModel modelo = (DefaultTableModel)jTable1.getModel();
        modelo.setNumRows(0);
         
        try
        {
           while (con_funcionario.resultset.next())
           {
                modelo.addRow(new Object [] {con_funcionario.resultset.getString("Codigo"),con_funcionario.resultset.getString("nome"),con_funcionario.resultset.getString("foneres"),con_funcionario.resultset.getString("fonecom"),con_funcionario.resultset.getString("fonecel"),con_funcionario.resultset.getString("email")});
           }
           
           con_funcionario.resultset.first();
         }  
         catch( SQLException erro )
         {
             JOptionPane.showMessageDialog(null,"Erro ao listar no JTable "+erro);
        }  
    }
    
    public void ordem_visualizacao(String Ordem)
    {
        ordenacao = Ordem;
        
        con_funcionario.executeSQL("select * from funcionario order by "+ ordenacao);           
        preencher_jtable();
        atualiza_combo_box_funcionario();
        
        try
        {
            con_funcionario.resultset.first();
        }
         catch (SQLException erro){
             JOptionPane.showMessageDialog(null,"Erro na ordenação dos dados "+erro);
        }
        
        mostrar_dados();
        
    }
    
    public void atualizaComboBoxLog()
    {
    // procedimento para atualizar jcombobox de log
    try
        {
            String sql = "select * from logradouro Where codigo ="+tf_codLog.getText();
            con_logradouro.executeSQL(sql);
            con_logradouro.resultset.first();
            cb_logradouro.setSelectedItem(con_logradouro.resultset.getString("nome"));
         }
      
        catch (SQLException erro)
        {
                JOptionPane.showMessageDialog(null,"Nao foi possivel localizar Logradouro");
                tf_codLog.requestFocus();

        }
   }

    public void atualizaComboBoxCid()
    {
    // procedimento para atualizar jcombobox de cidade
    try
        {
            String sql = "select * from cidade Where codigo ="+tf_codCidade.getText();
            con_cidade.executeSQL(sql);
            con_cidade.resultset.first();
            cb_cidade.setSelectedItem(con_cidade.resultset.getString("nome"));
         }
      
        catch (SQLException erro)
        {
                JOptionPane.showMessageDialog(null,"Nao foi possivel localizar cidade");
                tf_codCidade.requestFocus();
        }
    }
    
    public void atualizaComboBoxBairro()
    {
    // procedimento para atualizar jcombobox de bairro
    try
        {
            String sql = "select * from bairro Where codigo ="+tf_codBairro.getText();
            con_bairro.executeSQL(sql);
            con_bairro.resultset.first();
            cb_bairro.setSelectedItem(con_bairro.resultset.getString("nome"));
         }
      
        catch (SQLException erro)
        {
                JOptionPane.showMessageDialog(null,"Nao foi possivel localizar bairro");
                tf_codBairro.requestFocus();

        }
   
    }
    
    public void atualizaComboBoxCargo()
    {   
        // procedimento para atualizar jcombobox de cargo
        try
        {
            String sql = "select * from cargo Where codigo ="+tf_cargo.getText();
            con_cargo.executeSQL(sql);
            con_cargo.resultset.first();
            cb_cargo.setSelectedItem(con_cargo.resultset.getString("nome"));
        }
        
        catch (SQLException erro)
       {
            JOptionPane.showMessageDialog(null,"Nao foi possivel localizar cargo");
            tf_codBairro.requestFocus();
            
        }
        
        
    }
    
    
    
    
}
